<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
  <title>canvas 测试</title>
</head>

<body>
  <canvas id="myCanvas" width="200" height="100"></canvas>
  <script>
    const canvas = document.getElementById('myCanvas')
    const ctx = canvas.getContext('2d')

    // 绘制填充矩形
    // ctx.fillStyle = 'blue'
    // ctx.fillRect(10, 10, 50, 50)

    // 绘制描边矩形
    // ctx.strokeStyle = 'red'
    // ctx.strokeRect(70, 10, 50, 50)

    // 绘制圆形
    // ctx.beginPath()
    // ctx.arc(150, 35, 25, 0, 2 * Math.PI)
    // ctx.strokeStyle = 'green'
    // ctx.stroke()

    // 绘制文本
    ctx.font = '20px Arial'
    ctx.fillStyle = 'purple'
    ctx.fillText('Hello, Canvas!', 10, 90)
  </script>
</body>

</html>